package com.ep.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ep.common.utils.PageUtils;
import com.ep.modules.app.dao.AppExpertMapper;
import com.ep.modules.app.entity.AppExpert;
import com.ep.modules.app.entity.AppExpertExample;
import com.ep.modules.app.service.AppExpertService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppExpertServiceImpl implements AppExpertService {
    @Autowired
    private AppExpertMapper appExpertMapper;

    public PageUtils queryPage(Map<String, Object> params) {
        String searchKey = (String)params.get("searchKey");
        Long searchUserId = (Long)params.get("searchUserId");
        AppExpertExample example = new AppExpertExample();
        AppExpertExample.Criteria criteria = example.createCriteria();
        List<AppExpert> list = appExpertMapper.selectByExample(example);
        Page<AppExpert> page = new Page<>();
        page.setRecords(list);
        return new PageUtils(page);
    }

    public AppExpert getById(Long id) {
        return appExpertMapper.selectByPrimaryKey(id.intValue());
    }

    public void save(AppExpert entity) {
        appExpertMapper.insert(entity);
    }

    public void update(AppExpert entity) {
        appExpertMapper.updateByPrimaryKeySelective(entity);
    }

    public void deleteBatch(Long[] ids) {
        for (Long id : ids) {
                appExpertMapper.deleteByPrimaryKey(id.intValue());
        }
    }
}